package com.qiaofang.entity;

import com.qiaofang.common.model.BaseDomain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Formula;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

@Data
@Entity
@Table(name = "tm_partner_info")
public class PartnerInfo extends BaseDomain {

    @ApiModelProperty("账户名称")
    @Column(name = "account_name")
    private String accountName;

    @ApiModelProperty("联系人")
    @Column(name = "contacts")
    private String contacts;

    @ApiModelProperty("电话/手机")
    @Column(name = "phone")
    private String phone;

    @ApiModelProperty("账户类型:[{key:mechanism_account_type,values:[{no:0,alias:mechanism,remark:机构},{no:1,alias:individual,remark:个人}]}]")
    @Column(name = "account_type")
    private String accountType;

    @ApiModelProperty("公司类型/职位,对应系统参数表ID")
    @Column(name = "object_type")
    private Long objectType;

    @ApiModelProperty("地址")
    @Column(name = "adress")
    private String address;

    @ApiModelProperty("状态:[{key:mechanism_status,values:[{no:0,alias:disable,remark:停用},{no:1,alias:enable,remark:启用}]}]")
    @Column(name = "status")
    private String status;

    @ApiModelProperty("密码:MD5加密")
    @Column(name = "password")
    private String password;

    @ApiModelProperty("公司ID")
    @Column(name = "higherid")
    private String higherId;

    @Formula(value = " (select l.company_name from tm_company l where l.id = higherid order by l.create_time desc limit 1) ")
    private String companyName;

    @Formula(value = " (select l.company_type from tm_company l where l.id = higherid order by l.create_time desc limit 1) ")
    private String companyType;

    @ApiModelProperty("收款人")
    @Column(name = "payee")
    private String payee;

    @ApiModelProperty("邮箱")
    @Column(name = "mailbox")
    private String mailbox;

    @ApiModelProperty("卡号")
    @Column(name = "card_number")
    private String cardNumber;

    @ApiModelProperty("备注")
    @Column(name = "remark")
    private String remark;

    @ApiModelProperty("省份")
    @Column(name = "province")
    private Long province;

    @ApiModelProperty("城市")
    @Column(name = "city")
    private Long city;

    @ApiModelProperty("外部系统关联号")
    @Column(name = "external_number")
    private String externalNumber;

    @ApiModelProperty("微信openid")
    @Column(name = "wx_openid")
    private String wxOpenid;

    @Formula(value = " (select t.department_name from tm_department t where t.del_flag='0' and t.id = dept_id) ")
    private String deptName;

    @Formula(value = " (select GROUP_CONCAT(cm.premises_name) FROM tm_case_member cm left join tm_premises p on cm.premises_id = p.id WHERE cm.partner_id = id and p.del_flag = 0 and cm.del_flag = 0) ")
    private String stationedCase;

    @ApiModelProperty("")
    @Column(name = "dept_id")
    private Long deptId;

    @ApiModelProperty("数据查看权限:[{key:user_role,values:[{no:1,alias:NOTHING,remark:无},{no:2,alias:PERSONAL,remark:本人},{no:3,alias:DEPT,remark:本部},{no:4,alias:ALL,remark:全部}]}]")
    @Column(name = "user_role")
    private String userRole;

    @ApiModelProperty("用户角色")
    @Column(name = "user_roleid")
    private Long userRoleId;

    @ApiModelProperty("是否隐藏账号--(0: 否 99: 是)")
    @Column(name = "is_admin")
    private String isAdmin;

    @ApiModelProperty("性别: 0,男、1,女")
    @Column(name = "gender")
    private String gender;

    @ApiModelProperty("是否删除，0-否，1-是")
    @Column(name = "del_flag")
    private String delFlag;

}
